package nu.boomboom.smartfsync.impl;

import java.io.File;
import java.util.Iterator;

import nu.boomboom.smartfsync.IElement;

public class FilesIterator implements Iterator<IElement> {
	int i = 0;
	private final File[] files;

	public FilesIterator(File dir) {
		this.files = dir.listFiles();
	}

	@Override
	public boolean hasNext() {
		return i < files.length;
	}

	@Override
	public IElement next() {
		File file = files[i++];
		return file.isDirectory() ? new DirImpl(file) : new FileImpl(file);
	}

	@Override
	public void remove() {
		throw new UnsupportedOperationException();
	}
}
